package com.evola.conditionalformatting {
	import mx.collections.ICollectionView;

	/**
	 * Klasa sadrzi boje dobijene preko izraza.
	 * @author Sasa
	 *
	 */
	public class ViewGoalsSet {

		public var expressionString : String;
		public var goals : Array;

		public function ViewGoalsSet(expString : String, cols : Array) {
			expressionString = expString;
			goals = cols;
		}

		public function resolveGoalValue(goalType : String, value : Object, dataProvider : ICollectionView) : ViewGoal {

			var acceptedGoal : ViewGoal;

			for each (var goal : ViewGoal in goals) {
				
				if (goal.containsType(goalType) && goal.doesAccept(value, dataProvider)) {

					acceptedGoal = goal;
					break;
				}
			}

			return acceptedGoal;
		}
		
		public function toExpressionString() : String{
			
			var exp :String = "";
			
			if(goals){
				
				var count : int = 0;
				
				for each(var goal : ViewGoal in goals){
					
					if(count > 0)
						exp += ";";
					
					exp += goal.toExpressionString();
					
					count++;
				}
			}
			
			return exp;
		}

	}
}
